package TransactionImplementation

import (
	"reflect"
	"time"
	"SalaryPayment/TransactionApplication"
	"SalaryPayment/ModelImplementation"
	"SalaryPayment/DataBase"
)


type ServiceChargeTransaction struct {
	itsDate time.Time
	itsCharge float64
	itsMemberId int
	TransactionApplication.Transaction
}

func(sct *ServiceChargeTransaction) Execute() {
	e := DataBase.PayrollDatabase.Default.GetUnionMember(sct.itsMemberId)
	af := e.GetAffiliation()

	if reflect.TypeOf(af) == reflect.TypeOf(ModelImplementation.UnionAffiliation) {
		uaf := af.(*ModelImplementation.UnionAffiliation)
		uaf.AddServiceCharge(sct.itsDate, sct.itsCharge)
	} 
}